package com.edfu.core.institutemgt.persistence.entity;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.edfu.core.coursemgt.persistence.entity.ICourseMgtEntity;
import com.edfu.core.identitymgt.persistence.entity.UserEnrollmentEntity;



/**
 * 
 * @author sahsharm
 *	This class represents a batch like Computer Science - 2009
 */
@Entity
@Table(name="batch", uniqueConstraints=@UniqueConstraint(columnNames={"code"}))
public class BatchEntity implements ICourseMgtEntity,IInstituteMgtEntity {
	private long id ;
	private String code;
	private String title ;
	private String description ;
	private Date createdOn;
	private Date lastModifiedOn;
	private Date startDate ;
	private Date endDate ;
	private Set<UserEnrollmentEntity> enrollments;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Date getCreatedOn() {
		return createdOn;
	}
	public void setCreatedOn(Date createdOn) {
		this.createdOn = createdOn;
	}
	public Date getLastModifiedOn() {
		return lastModifiedOn;
	}
	public void setLastModifiedOn(Date lastModifiedOn) {
		this.lastModifiedOn = lastModifiedOn;
	}
	public Date getStartDate() {
		return startDate;
	}
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	public Date getEndDate() {
		return endDate;
	}
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	
//	@ManyToOne
//	@JoinColumn(name = "branch_id", nullable = false)
//	public BranchEntity getBranch() {
//		return branch;
//	}
//	public void setBranch(BranchEntity branch) {
//		this.branch = branch;
//	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	
	@OneToMany(mappedBy = "batch", fetch= FetchType.EAGER, cascade=CascadeType.ALL)
	public Set<UserEnrollmentEntity> getEnrollments() {
		return enrollments;
	}
	public void setEnrollments(Set<UserEnrollmentEntity> enrollments) {
		this.enrollments = enrollments;
	}
	

}
